package com.example.weather.interfaceimpl;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.weather.R;
import com.example.weather.utils.GridViewInterface;

import java.util.ArrayList;
import java.util.Map;

/**
 * Created by hanjun on 2016/7/31.
 */
public class PhoneOperator implements GridViewInterface {
    private Map<String,Object> map;
    public View handle(View convertView, ViewGroup parent, int position, Context context, ArrayList<Map<String, Object>> list, Object object) {
        ViewHolder holder;
        map = list.get(position);
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.phone_book, null);
            holder = new ViewHolder();
            holder.nametv = (TextView) convertView.findViewById(R.id.name);
            holder.numbertv = (TextView) convertView.findViewById(R.id.number);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.nametv.setText((String)map.get("phoneName"));
        holder.numbertv.setText((String)map.get("phoneNumber"));
        return convertView;
    }

    private static class ViewHolder {
        TextView nametv;
        TextView numbertv;
    }

}